﻿@{
    var F = Html.F();

    var _bodyClass = "f-bgcolor";
    if (ViewBag.BodyBGColor == false)
    {
        _bodyClass = "";
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>@Html.Raw(ViewBag.Title)</title>
    @if (ViewBag.SourceFiles != null)
    {
        <meta name="sourcefiles" content="@ViewBag.SourceFiles" />
    }

    @F.RenderCss()

    <link href="~/res/css/common.css?v@(GlobalConfig.ProductVersion)" rel="stylesheet" type="text/css" />

    <link href="~/res/css/animate-3.5.2.min.css" rel="stylesheet" />
    <link href="~/res/css/FineUIOvereide.css" rel="stylesheet" />
    @RenderSection("head", false)
</head>
<body class="@_bodyClass">

    @Html.AntiForgeryToken()

    @{
        var pm = F.PageManager;

        // 主题
        var themeCookie = Context.Request.Cookies["Theme"];
        //if (!String.IsNullOrEmpty(themeCookie))
        //{
        //    Theme theme;
        //    if (Enum.TryParse<Theme>(themeCookie, true, out theme))
        //    {
        //        // 先清空CustomTheme，再设置Theme
        //        pm.CustomTheme(String.Empty);
        //        pm.Theme(theme);
        //    }
        //    else
        //    {
        //        pm.CustomTheme(themeCookie);
        //    }
        //}
        pm.CustomTheme("meixianghao");

        // 语言
        var langCookie = Context.Request.Cookies["Language"];
        if (!String.IsNullOrEmpty(langCookie))
        {
            Language lang;
            if (Enum.TryParse<Language>(langCookie, true, out lang))
            {
                pm.Language(lang);
            }
            else
            {
                pm.CustomLanguage(langCookie);
            }
        }

        // 加载动画
        var loadingCookie = Context.Request.Cookies["Loading"];
        if (!String.IsNullOrEmpty(loadingCookie))
        {
            int loadingNumber = Convert.ToInt32(loadingCookie);
            pm.LoadingImageNumber(loadingNumber);
        }

        // 1. 仅显示基础版示例， 2. 基础版
        // 上述两种情况都要禁用EnableAnimation、DisplayMode、MobileAdaption
        bool showOnlyBase = false;
        var showOnlyBaseCookie = Context.Request.Cookies["ShowOnlyBase"];
        if (!String.IsNullOrEmpty(showOnlyBaseCookie))
        {
            showOnlyBase = Convert.ToBoolean(showOnlyBaseCookie);
        }

        if (showOnlyBase || Constants.IS_BASE)
        {
            pm.MobileAdaption(false);
            pm.DisplayMode(FineUICore.DisplayMode.Normal);
            pm.EnableAnimation(false);
        }
        else
        {
            // 显示模式
            var modeCookie = Context.Request.Cookies["DisplayMode"];
            if (!String.IsNullOrEmpty(modeCookie))
            {
                try
                {
                    pm.DisplayMode((DisplayMode)Enum.Parse(typeof(DisplayMode), modeCookie, true));
                }
                catch (Exception)
                {
                    pm.DisplayMode(DisplayMode.Normal);
                }
            }

            // 是否移动页面
            var area = ViewContext.RouteData.Values["area"];
            var areaName = (area == null ? "" : area.ToString().ToLower());
            var controllerName = ViewContext.RouteData.Values["controller"].ToString().ToLower();
            if (controllerName == "mobile" || areaName.StartsWith("mobile"))
            {
                // 强制设为大字体、移动设备自适应
                pm.DisplayMode(DisplayMode.Large);
                pm.MobileAdaption(true);
            }
        }
    }
    @F.PageManager

    @RenderSection("body", true)

    @F.RenderScript()


    <script>
        var pburl = '@Url.Action("")';
    </script>
    <script src="~/res/js/FineUIOvereide.js"></script>
    <script type="text/javascript" src="~/res/js/common.js?v@(GlobalConfig.ProductVersion)"></script>
    @RenderSection("script", false)
</body>
</html>
